import request from '@/router/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-admin/bom/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};
export const getAllList = (params) => {
  return request({
    url: '/api/mes-admin/bom/get-all-bom-vo',
    method: 'get',
    params: { ...params }
  });
};

// BOM详情 新增
export const addBomDetail = (row) => {
  return request({
    url: 'api/mes-admin/bom/detail/submit',
    method: 'post',
    data: row
  });
};
// BOM详情 删除
export const removeBomDetail = (ids) => {
  return request({
    url: 'api/mes-admin/bom/detail/remove',
    method: 'get',
    params: {
      ids
    }
  });
};

// BOM替代料 分页
export const getReplacePartlList = (bomDetailId, params) => {
  return request({
    url: 'api/mes-admin/bom/detail/replace/list',
    method: 'get',
    params: {
      ...params,
      bomDetailId
    }
  });
};

export const getReplacementList = (current, size, params) => {
  return request({
    url: '/api/mes-admin/bom/part/replacement/list',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const getDetail = (current, size, params) => {
  return request({
    url: '/api/mes-admin/bom/page-bom-detail',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const remove = (id) => {
  return request({
    url: '/api/mes-admin/bom/remove',
    method: 'get',
    params: {
      id
    }
  });
};

export const add = (row) => {
  return request({
    url: '/api/mes-admin/bom/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/mes-admin/bom/submit',
    method: 'post',
    data: row
  });
};

export const getLazyList = (bomId, parentId, params) => {
  return request({
    url: '/api/mes-admin/bom/detail/lazy-list',
    method: 'get',
    params: {
      ...params,
      bomId,
      parentId
    }
  });
};

export const getBomDetailMenuTree = (bomId) => {
  return request({
    url: 'api/mes-admin/bom/tree',
    method: 'get',
    params: {
      bomId
    }
  });
};

export const getBomDetail = (id) => {
  return request({
    url: 'api/mes-admin/bom/detail/info',
    method: 'get',
    params: {
      id
    }
  });
};

export const getReplacePartDatail = (id) => {
  return request({
    url: 'api/mes-admin/bom/detail/replace/info',
    method: 'get',
    params: {
      id
    }
  });
};

export const addReplacePart = (row) => {
  return request({
    url: 'api/mes-admin/bom/detail/replace/submit',
    method: 'post',
    data: row
  });
};

export const removeReplacePart = (ids) => {
  return request({
    url: 'api/mes-admin/bom/detail/replace/remove',
    method: 'get',
    params: {
      ids
    }
  });
};

export const getBomList = (current, size, params) => {
  return request({
    url: 'api/mes-admin/bom/detail/part-page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};
